/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ejb;

import entidades.Alumno;
import entidades.Final;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author Administrador
 */
@Stateless
public class FinalFacade extends AbstractFacade<Final> {
    @PersistenceContext(unitName = "SistemasDistribuidos-ejbPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public FinalFacade() {
        super(Final.class);
    }
    
    public List<Final> getFinalByAlumno(Alumno alumno){
        Query query = em.createQuery("SELECT final FROM Final final JOIN final.inscripcion inscri JOIN inscri.alumno alu WHERE alu.idPersona = :idPersona");
        query.setParameter("idPersona", alumno.getIdPersona());
        return query.getResultList();
    }
    
}
